package com.culture.config.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.culture.config.common.util.BeanUtil;
import com.culture.config.dao.entity.EventLog;
import com.culture.config.dao.mapper.EventLogMapper;
import com.culture.config.model.po.LogPageParam;
import com.culture.config.model.vo.LogVO;
import com.culture.config.service.EventLogService;
import com.culture.config.wrapper.EventLogWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service
public class EventLogServiceImpl implements EventLogService {
	@Resource 
	private EventLogMapper eventLogMapper;
	
	@Override
	public void addEventLog(String eventName, String eventData) {
		log.info("addEventLog:{},{}",eventName,eventData);
		this.eventLogMapper.add(EventLogWrapper.wrapEventLogAdd(eventName, eventData));		
	}

	@Override
	public Page<LogVO> page(LogPageParam param) {
		PageHelper.startPage(param.getPageNum(),param.getPageSize());
		Page<EventLog> logList = this.eventLogMapper.page(EventLogWrapper.wrapLogQuery(param));      
		return BeanUtil.copyPageProperties(logList, LogVO.class);
	}

}
